import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes=[
  {
    path:'/index',
    component:()=>import('../pages/index.vue'),
    children:[
      {
        path:'/home',
        component:()=>import('../views/home.vue'),
        name:"小U商城"
      },
      {
        path:'/cate',
        component:()=>import('../views/cate.vue'),
        name:'分类'
      },{
        path:'/cart',
        component:()=>import('../views/cart.vue'),
        name:'购物车'
      },{
        path:'/mine',
        component:()=>import('../views/mine.vue'),
        name:'个人中心'
      },
      {
        path:'',
        redirect:'/home'
      }
    ]
  },
  {
    path:'/detail',
    component:()=>import('../pages/detail.vue'),
    name:'商品详情'
  },
  {
    path:'/list',
    component:()=>import('../pages/list.vue'),
    name:'商品列表'
  },
  {
    path:'/register',
    component:()=>import('../pages/register.vue'),
    name:'注册'
  },
  {
    path:'/login',
    component:()=>import('../pages/login.vue'),
    name:'登录'
  },
  {
    path:'/order',
    component:()=>import('../pages/order.vue'),
    name:'订单页'
  },
  {
    path:'*',
    redirect:'/index'
  }
]

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
